package settingsapp.settings.toggle;

import android.content.Context;
import ece.settingsapp.R;

public class SettingOrientationLock extends ToggleSettingChanger
{
	public SettingOrientationLock(Context context, int intRepresentation)
	{
		super(context, intRepresentation);
		this.context = context;
	}
	
	protected void setValue(boolean value)
	{
		// TODO find fix similar to AirplaneMode sending Intent to
		// register update on emulator
		android.provider.Settings.System.putInt(context.getContentResolver(),
		android.provider.Settings.System.ACCELEROMETER_ROTATION, value ? 1 : 0);
	}

	@Override
	public void readValue()
	{
		isOn = (android.provider.Settings.System.getInt(context.getContentResolver(),
			android.provider.Settings.System.ACCELEROMETER_ROTATION, isOn ? 1 : 0) != 0);
	}

	@Override
	public int getResourceOn()
	{
		return R.drawable.autorotate_on;
	}

	@Override
	public int getResourceOff()
	{
		return R.drawable.autorotation_off;
	}
}
